/*
* proxy interface
* */
const httpProxy = require('http-proxy'),
      createProxy = httpProxy.createProxyServer();

const global_urls = require('./api.conf');


// 设置代理
const createProxyServer = function(req, res, next) {
    createProxy.web(req, res, {
        target: ''
    })
    // more ...


};

// 过滤请求，不需要代理的请求添加中间件
const filterProxy = (path, middleware) => (req, res, next) => {
    if (req.path.indexOf(path + '/') >= 0) {
        return next();
    } else {
        return middleware(req, res, next);
    }
};


module.exports = {
    createProxyServer,
    filterProxy
};
